babl: add babl_model_is, utility function for checking model equivalence
authorØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 21:35:59 +0000 (23:35 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 21:36:01 +0000 (23:36 +0200)
This creates an on the fly model with the same space as the one compared with
and does pointer equivalence. Using it makes for less verbose code.

babl/babl.c
babl/babl.h
export-symbols

index c734fb3c0d46a74e95dfaad9f7ed6ef0e94a1bf2..3d7573ef362c0365a17f3a11cd9b007f9c215178 100644 (file)
@@ -180,3 +180,11 @@ babl_exit (void)
 #endif
     }
 }
+
+#undef babl_model_is
+
+int babl_model_is (const Babl *babl, const char *model)
+{
+  return ((babl)==babl_model_with_space(model, babl));
+}
+
index 660138f72d01bceb01974cf56ffbee8d2f1d1ca2..f0dc85221758923c395ca5380d8e390758d0bd19 100644 (file)
@@ -501,6 +501,9 @@ const Babl * babl_trc (const char *name);
  * query thechromaticities of white point and primaries as well as trcs
  * used for r g a nd b, all arguments mights be NULL.
  */
+int babl_model_is (const Babl *babl, const char *model);
+
+#define babl_model_is(babl,model)  ((babl)==babl_model_with_space(model,babl))
 
 void babl_space_get (const Babl *space,
                      double *xw, double *yw,
index f9d0a1cf906a5aed7a053bcb67e18cc8ab3d3d2c..130f616a8864e6bc5e191bc8aee191ee5514c6f7 100644 (file)
@@ -31,6 +31,7 @@ babl_init
 babl_introspect
 babl_malloc
 babl_model
+babl_model_is
 babl_model_with_space
 babl_model_new
 babl_new_palette